<?php

namespace app\controller\bossManager;

use app\validate\PageValidate;
use app\validate\P2pUpgradeSelectorValidate;
use app\service\P2pUpgradeSelectorService;
use app\service\P2pUpgradeService;

class P2pUpgradeSelectorController extends WebBossController{
    public function initValidate(){        
        $this->validate = new P2pUpgradeSelectorValidate();
    }

    public function list_action(){  
        $input = $this->check();        
        $page = $this->check('pageInfo',null,(new PageValidate()));        
        $data = P2pUpgradeSelectorService::getListInfo($input,$page);
        $total = P2pUpgradeSelectorService::getListCountInfo($input);
        return self::ok(self::formatPageData($page,$total,$data));    
    }

    public function set_action(){  
        $input = $this->check();
        $res = P2pUpgradeSelectorService::edit($input); 
        return self::ok($res);
    }

 
    public function del_action(){ 
        $input = $this->check();
        $res = P2pUpgradeSelectorService::delById($input['id']); 
        return self::ok($res);
    }

    public function check_action(){
        $input = $this->check();   
        $dn = isset($input['dn']) ? $input['dn'] : '';
        $sn = isset($input['sn']) ? $input['sn'] : '';
        $pk = isset($input['pk']) ? $input['pk'] : '';
        $data = P2pUpgradeService::getConfByFilter($dn,$sn,$pk);
        return self::ok($data); 
    }

}